//
//  Menu.m
//  Archer
//
//  Created by gu steve on 3/21/12.
//  Copyright (c) 2012 SteveGu. All rights reserved.
//

#import "Menu.h"

@interface Menu()
@end

@implementation Menu

@synthesize caption = _caption;
@synthesize initRect = _initRect;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    _initRect = frame;
    
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0 green:220 blue:221 alpha:255];
        
        _caption = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 50)];
        _caption.font = [UIFont systemFontOfSize:26.0];;
        _caption.text = @"ProReader";
        _caption.textAlignment = UITextAlignmentCenter;
        _caption.textColor = [UIColor whiteColor];
        _caption.backgroundColor = [UIColor clearColor];
        
        [self addSubview:_caption];
        
    }
    return self;
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */

-(void) setFrame:(CGRect)frame
{
    [_caption setFrame:CGRectMake(0, 0, frame.size.width,50)];
    
    _initRect = frame;
    
    [super setFrame:frame];
}

-(void) Show
{
    CGRect rect = CGRectMake(_initRect.origin.x, 0, _initRect.size.width, 250);
    
    [UIView beginAnimations:@"showMenu" context:nil];
    [UIView setAnimationDuration:0.3f];
    [self setFrame:rect];
    [UIView commitAnimations];
}

-(void) Hide
{
    CGRect rect = CGRectMake(_initRect.origin.x
                             , 0, _initRect.size.width, 50);
    
    [UIView beginAnimations:@"hideMenu" context:nil];
    [UIView setAnimationDuration:0.2f];
    [self setFrame:rect];
    [UIView commitAnimations];
}


-(void) dealloc
{
    [_caption release];
    
    [super dealloc];
}

@end
